package dhm.com.dhmshop.adapter.order;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagAdapter;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.ArrayList;
import java.util.List;

import dhm.com.dhmshop.R;
import dhm.com.dhmshop.adapter.home.GoodsParamAdapter;
import dhm.com.dhmshop.adapter.mine.ShowIChildAdapter;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.entity.GetOneCategory;
import dhm.com.dhmshop.framework.module.commodity.entity.OneGoodsEntity;

/**
 * Created by admin
 * 2019/4/29
 * 所有订单适配器
 */
public class ParamTypeAdapter extends RecyclerView.Adapter<ParamTypeAdapter.ViewHolder> {

    private List<OneGoodsEntity.SpecBean> imageList;
    private Context context;


    public ParamTypeAdapter(Context context) {
        this.imageList = new ArrayList<>();
        this.context = context;
    }


    public void setImageList(List<OneGoodsEntity.SpecBean> paramList) {
        this.imageList = paramList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        ViewHolder viewHolder;
        View view = LayoutInflater.from(context).inflate(R.layout.item_orderpop, viewGroup, false);
        viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {

        viewHolder.param_name.setText(imageList.get(i).getName());
        viewHolder.recy.setVisibility(View.VISIBLE);

        GridLayoutManager manager = new GridLayoutManager(context, 3);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        viewHolder.recy.setLayoutManager(manager);

        GoodsParamAdapter goodsParamAdapter = new GoodsParamAdapter(context);
        goodsParamAdapter.setaddClick(new GoodsParamAdapter.OnShopClick() {
            @Override
            public void item(int posttion) {
                onIntentClick.item(i, posttion);
            }
        });

        viewHolder.recy.setAdapter(goodsParamAdapter);
        goodsParamAdapter.setShopList(imageList.get(i).getList());

    }

    @Override
    public int getItemCount() {
        return imageList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public RecyclerView recy;
        public TextView param_name;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            param_name = itemView.findViewById(R.id.param_name);
            recy = itemView.findViewById(R.id.param_value);
        }
    }

    private OnClick onClick;

    public void setdeleteClick(OnClick onClick) {
        this.onClick = onClick;
    }

    public interface OnClick {
        void item(int posttion);
    }

    private OnIntentClick onIntentClick;

    public void setaddClick(OnIntentClick onClick) {
        this.onIntentClick = onClick;
    }

    public interface OnIntentClick {
        void item(int posttion, int childposttion);
    }


}

